import { View, Text, Button, TextInput } from "react-native";
import { useState } from "react";

export default function Detail({ navigation }) {
  const [postContent, setPostContent] = useState("");

  const go2Home = () => {
    navigation.navigate({
      name: "Home",
      params: {
        postContent,
      },
      merge: true,
    });
  };

  const changeTitle = () => {
    navigation.setOptions({
        title:"详情页面222"
    })
  }

  return (
    <View style={styles.container}>
      <Text>详情页面</Text>
      <TextInput
        placeholder="传递信息"
        value={postContent}
        onChangeText={setPostContent}
      />
      <Button title="返回" onPress={go2Home} />
      <Button title="修改标题" onPress={changeTitle} />
    </View>
  );
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
  },
});
